<?php require "styles.html" ?>

<?php if (count($this->messages)): ?>
<div id="zs-message">
<?php echo join('<br/>', $this->messages) ?>
</div>
<?php endif; ?>

<?php if ($this->canCreate): ?>
<a class="zs-btn-add" href="<?php echo $this->url(array('module' => $this->module, 'controller' => $this->controller, 'action' => 'create'), 'default', true)?>"><?php echo $this->translate('New %1$s', $this->entityTitle) ?></a>
<?php endif; ?>

<?php if ($this->searchForm): ?>
<script type="text/javascript">
function ssfResetForm(form)
{
    for(i = 0; i < form.elements.length; i++) {
        fieldType = form.elements[i].type.toLowerCase();
        switch (fieldType) {
            case "text": case "password":
            case "textarea": case "hidden":
                form.elements[i].value = "";
                break;

            case "radio": case "checkbox":
                if (form.elements[i].checked)
                    form.elements[i].checked = false;
                break;

            case "select-one": case "select-multi":
                form.elements[i].selectedIndex = -1;
                break;

            default: break;
        }
    }
}
</script>
<div <?php echo $this->searchActive ? 'class="zs-search-active" title="' . $this->translate('Search filter is active') . '"' : 'class="zs-search"'?> >
<?php echo $this->searchForm; ?>
</div>
<?php endif; ?>

<?php $cycle = $this->cycle(array("even", "odd")); ?>
<?php if (count($this->entries)): ?>
<table class="zs-entity-list <?php echo 'zs-' . $this->entityTitle ?>" cellspacing="0" cellpadding="0" border="0">
    <thead>
        <tr>
<?php foreach ($this->headers AS $header): ?>
            <th><?php echo $header; ?></th>
<?php endforeach; ?>
<?php if ($this->canUpdate || $this->canDelete): ?>
            <th>Actions</th>
<?php endif; ?>
        </tr>
    </thead>
    <tbody>
<?php foreach ($this->entries as $entry): ?>
    <tr <?php echo 'class="zs-row-' . $cycle->next() . '"' ?>>
        <?php
        foreach($entry as $field => $value):
            if ($field != 'pkParams'): ?>
        <td><?php echo $value; ?></td>
            <?php endif;
        endforeach; ?>
        <?php if ($this->canUpdate || $this->canDelete): ?>
        <td>
            <?php if ($this->canUpdate): ?>
            <a href="<?php echo $this->url(array_merge(array('module' => $this->module, 'controller' => $this->controller, 'action' => 'update'), $entry['pkParams']), 'default', true) ?>" class="zs-btn-edit">edit</a>
            <?php endif; ?>
            <?php if ($this->canDelete): ?>
            <a href="<?php echo $this->url(array_merge(array('module' => $this->module, 'controller' => $this->controller, 'action' => 'delete'), $entry['pkParams']), 'default', true) ?>" onclick="return confirm('<?php echo $this->translate('Do you really want to delete the selected %1$s?', $this->entityTitle) ?>');" class="zs-btn-delete">delete</a>
            <?php endif; ?>
        </td>
        <?php endif; ?>
    </tr>
<?php endforeach; ?>
    </tbody>
</table>
<?php if (isset($this->paginator)): ?>
<?php echo $this->paginationControl($this->paginator, 'Sliding', 'scaffolding/pagination.phtml') ?>
<?php endif; ?>
<?php else: ?>
    <p><strong>No records have been found</strong></p>
<?php endif; ?>